public class demo35 {
    //找出字符串中第一个匹配项的下标（双指针）
    class Solution {
        public int strStr(String hay, String ned) {
            int len1 = hay.length();
            int len2 = ned.length();
            //char[] p  = hay.toCharArray(), q = ned.toCharArray();
            if(len1<len2) return -1;
            for(int i = 0;i<= len1-len2;i++)
            {
                int j = 0;
                int k = i;
                while(j<len2 && ned.charAt(j)==hay.charAt(k))
                {
                    j++;
                    k++;
                }
                if( j == len2) return i;
            }
            return -1;
        }
    }
}
